<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
<head>
<title>Introduction to PyQt4</title>
<link rel="stylesheet" href="/cfg/format.css" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="keywords" content="PyQt, PyQt4, Introduction, tutorial, Python, Linux">
<meta name="description" content="This chapter is an introduction to the PyQt4 toolkit.">
<meta name="language" content="en">
<meta name="author" content="Jan Bodnar">
<meta name="distribution" content="global">

<script type="text/javascript" src="/lib/jquery.js"></script>
<script type="text/javascript" src="/lib/common.js"></script>

</head>

<body>

<div class="container">

<div id="wide_ad" class="ltow">
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* 160x600, August 2011 */
google_ad_slot = "2484182563";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<div class="content">


<a href="/" title="Home">Home</a>&nbsp;
<a href=".." title="Home">Contents</a>


<h1>Introduction to PyQt4</h1>


<p>
This is an introductory PyQt4 tutorial. The purpose of this tutorial 
is to get you started with the PyQt4 toolkit. The tutorial has been 
created and tested on Linux.
</p>

<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* NewSquare */
google_ad_slot = "0364418177";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script> 
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
</script> 

<h2>About PyQt4</h2>

<p>
PyQt4 is a toolkit for creating GUI applications. It is a blending of Python 
programming language and the successfull Qt library. Qt library is one of 
the most powerful GUI libraries. The official home site for PyQt4 is on
<a href="http://www.riverbankcomputing.co.uk/news">www.riverbankcomputing.co.uk/news</a>
It was developed by <b>Phil Thompson</b>. 
</p>

<p>
PyQt4 is implemented as a set of Python modules. It has over 300 classes and 
almost 6000 functions and methods. It is a multiplatform toolkit. It runs on 
all major operating systems. Including Unix, Windows and Mac.
PyQt4 is dual licenced. Developers can choose between GPL and commercial licence. 
Previously, GPL version was available only on Unix. Starting from PyQt 
version 4, GPL licence is available on all supported platforms.
</p>

<p>
Because there are a lot of classes available, they have been 
divided into several modules. 
</p>

<ul>
<li>QtCore</li>
<li>QtGui</li>
<li>QtNetwork</li>
<li>QtXml</li>
<li>QtSvg</li>
<li>QtOpenGL</li>
<li>QtSql</li>
</ul>


<p>
The <b>QtCore</b> module contains the core non-gui functionality. This 
module is used for working with time, files and directories, various data 
types, streams, urls, mime types, threads or processes. The <b>QtGui</b> 
module contains the graphical components and related classes. These include 
for example buttons, windows, status bars, toolbars, sliders, bitmaps, 
colours, fonts etc. The <b>QtNetwork</b> module contains the classes for 
network programming. These classes facilitate the coding of TCP/IP and UDP clients and 
servers by making the network programming easier and more portable. 
The <b>QtXml</b> contains classes for working with XML files. This module 
provides implementation for both SAX and DOM APIs.
The <b>QtSvg</b> module provides classes for displaying the contents of 
SVG files. Scalable Vector Graphics (SVG) is a language for describing 
two-dimensional graphics and graphical applications in XML.
The <b>QtOpenGL</b> module is used for rendering 3D and 2D graphics 
using the OpenGL library. The module enables seamless integration of 
the Qt GUI libary and the OpenGL library. The <b>QtSql</b> module 
provides classes for working with databases. 
</p>


<h2>Python</h2>

<p> 
<img src="/img/gui/pyqt4/pythonlogo.png" style="float: left;" alt="python logo"> 
Python is a general-purpose, dynamic, object-oriented programming language.
The design purpose of the Python language emphasizes programmer productivity 
and code readability. Python was initially developed by <b>Guido van Rossum</b>. 
It was first released in 1991. Python was inspired by ABC, Haskell, Java, Lisp, Icon
and Perl  programming languages. Python is a high level, general purpose, 
multiplatform, interpreted language.  
Python is a minimalistic language. One of its most visible features is that it does 
not use semicolons nor brackets. Python uses indentation instead. 
There are two main branches of Python currently. Python 2.x and Python 3.x. Python 3.x
breaks backward compatibility with previous releases of Python. It was created to
correct some design flaws of the language and make the language more clean. 
The most recent version of Python 2.x is 2.7.1, and of Python 3.x 3.1.3.
This tutorial covers Python 2.x versions. Most of the code is written in Python
2.x versions. It will take some time till the software base and programmers will 
migrate to Python 3.x. 
Today, Python is maintained by a large group of volunteers worldwide. 
Python is open source software. 
</p> 
 
<p> 
Python is an ideal start for those, who want to learn programming. 
</p> 
 
<p> 
Python programming language supports several programming styles. It does not 
force a programmer to a specific paradigm.  Python supports object-oriented and 
procedural programming. There is also a limited support for functional programming.
</p> 
 
<p> 
The official web site for the Python programming language is 
<a href="http://python.org">python.org</a> 
</p> 

<p>
As of August 2011, <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html">TIOBE Index</a> 
ranks the Python language as the 8th most popular language. On <a href="http://www.langpop.com">
langpop.com</a> site it scores on the 6th place. 
</p>
 
<p> 
Perl, Python and Ruby are the most widely used scripting languages. They 
share many similarities. They are close competitors. 
</p> 


<h2>Python toolkits</h2>

<p>
For creating graphical user interfaces, Python programmers can choose among 
three decent options. PyQt4, PyGTK and wxPython.
Which toolkit to choose, depends on the circumstances. 
</p>

<p>
Due to some licensing issues and technical requirements a new binding
of Qt to the Python language has been developed. The project is called
<a href="http://www.pyside.org/">PySide</a>. 
PySide provides a high level compatibility with the PyQt4 toolkit. 
</p>

<p>
This chapter was an introduction to PyQt4 toolkit.
</p>


<div class="center"> 
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* horizontal */
google_ad_slot = "1734478269";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script> 
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
</script> 
</div>
<br> 



<div class="botNav, center">
<span class="botNavItem"><a href="/">Home</a></span> ‡ <span class="botNavItem"><a href="..">Contents</a></span> ‡ 
<span class="botNavItem"><a href="#">Top of Page</a></span>
</div>


<div class="footer">
<div class="signature">
<a href="/">ZetCode</a> last modified October 10, 2011  <span class="copyright">&copy; 2007 - 2013 Jan Bodnar</span>
</div>
</div>

</div> <!-- content -->

</div> <!-- container -->

</body>
</html>

